<?php
// 连接数据库
require '../script/mysqlconfig.php';
$conn = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
if ($conn->connect_error) {
    die("连接数据库失败: " . $conn->connect_error);
}

// 查询数据库
$sql = "SELECT * FROM users";
$result = $conn->query($sql);

// 生成表格
if ($result->num_rows > 0) {
    echo "<table border='1' style='border-collapse: collapse;'>";
    echo "<tr><th>ID</th><th>用户</th><th>密码</th><th>用户组</th><th>角色</th><th>备注</th><th>功能区</th></tr>";
    while ($row = $result->fetch_assoc()) {
        echo "<tr><td>".$row["id"]."</td><td>".$row["name"]."</td><td>".$row["password"]."</td><td>".$row["group"]."</td><td>".$row["role"]."</td><td>".$row["info"]."</td><td><a href='account4edit.php?id=".$row['id'] . "'>编辑</a></td><td><a href='accountdel.php?accountname=".$row['name'] . "'>删除</a></td></tr>";
    }
    echo "</table>";
} else {
    echo "数据库中没有数据";
}

// 关闭数据库连接
$conn->close();
?>